﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using PsychSurvey.ResearchId;

namespace PsychSurvey
{
    // NOTE: If you change the interface name "IAdminServiceWCF" here, you must also update the reference to "IAdminServiceWCF" in Web.config.    
    [ServiceContract]
    public interface IAdminServiceWCF    
    {
        //Main Admin Query
        [OperationContract]
        void GetSurveyData(
            out List<Study> Studies, 
            out List<Condition> Conditions, 
            out List<StudyWave> Waves,
            out List<StudyWaveSurvey> StudyWaveSurveys,
            out List<Survey> Surveys,
            out List<SurveySurveyPage> SurveySurveyPages,
            out List<SurveyPage> Pages,
            out List<StudyClaim> StudyClaims);

        //Main Participant Query
        [OperationContract]
        void ResumeStudy(int IndividualId, Guid StudyId
            , bool IsTesting
            , out Study myStudy, out Condition myCondition
            , out List<StudyConsolidatedOrderedIndividualResult> SurveyPages
            , out DateTime? NextWaveStartDate
            , out DateTime? NextWaveEndDate
            );
        [OperationContract]
        List<Claim> GetClaims();
        [OperationContract]
        List<StudyResultsIndividualEmail> GetStudyResults(Guid StudyId);
        [OperationContract]
        void DeleteStudyResults(Guid StudyId, int IndividualId);
        [OperationContract]
        List<Survey> GetSurveyList();
        #region Study
        [OperationContract]
        List<Study> GetStudyList();
        [OperationContract]
        Study GetStudy(Guid StudyId);
        [OperationContract]
        Study CreateStudy(out List<Condition> Conditions, out List<StudyWave> Waves);
        [OperationContract]
        bool UpdateStudy(Study StudyToUpdate);
        [OperationContract]
        bool DeleteStudy(Guid StudyId);
        [OperationContract]
        string GetStudyUrl(Guid Study);
        [OperationContract]
        string GetStudyDevelopmentUrl(Guid Study);
        [OperationContract]
        List<Claim> GetClaimsNotAdded(Guid StudyId);
        [OperationContract]
        List<Claim> GetClaimsAdded(Guid StudyId);
        [OperationContract]
        bool UpdateClaims(Guid Study, int[] AllClaims, int[] AnonymousClaims);
        [OperationContract]
        StudyConsolidatedOrderedResults GetNextSurveyPage(Guid StudyId, int IndividualId);
        [OperationContract]
        StudyConsolidatedOrderedResults GetPreviousSurveyPage(Guid StudyId, int IndividualId, int StudyWaveId, Guid SurveyId, int SurveyPageId);
        [OperationContract]
        StudyConsolidatedOrderedResults GetNextSurveyPage2(Guid StudyId, int IndividualId, int StudyWaveId, Guid SurveyId, int SurveyPageId);
        //[OperationContract]
        //void GetSurveyPageResults(Guid StudyId, int IndividualId, int StudyWaveId, Guid SurveyId, int SurveyPageId, out string[] Names, out string[] Values);        
        [OperationContract]
        void ReportSurveyPageResults(Guid StudyId, int IndividualId, int StudyWaveId,
            Guid SurveyId, int SurveyPageId, string[] Names, string[] Values);
        [OperationContract]
        void DeleteResults(Guid StudyId);
        [OperationContract]
        void CountParticipants(Guid StudyId, out int TotalParticipants, out List<ConditionCount> ConditionCount);
        [OperationContract]
        void UpdateClaimsForStudy(Guid StudyId, List<Claim> ClaimsAdded);
        #endregion
        #region Conditions
        [OperationContract]
        List<Condition> GetConditions(Guid StudyId);
        [OperationContract]
        Condition GetCondition(int ConditionId);
        [OperationContract]
        Condition CreateCondition(Guid StudyId);
        [OperationContract]
        bool DeleteCondition(int ConditionId);
        [OperationContract]
        bool UpdateCondition(Condition ConditionToSave);
        #endregion
        #region StudyWave
        [OperationContract]
        List<StudyWave> GetStudyWaves(Guid StudyId);
        [OperationContract]
        List<StudyWave> GetStudyWavesForConditionId(int ConditionId);
        [OperationContract]
        StudyWave GetStudyWave(int StudyWave);
        [OperationContract]
        bool UpdateStudyWave(StudyWave myStudyWave);
        [OperationContract]
        StudyWave CreateWave(Guid StudyId);
        [OperationContract]
        bool DeleteStudyWave(int StudyWaveId);
        [OperationContract]
        bool DeleteStudyWaveSurvey(int StudyWaveId, int ConditionId);
        [OperationContract]
        bool UpdateStudyWaveSurvey(StudyWaveSurvey mySws);
        [OperationContract]
        StudyWaveSurvey CreateStudyWaveSurvey(StudyWaveSurvey sws);
        #endregion
        #region Survey
        [OperationContract]
        List<Survey> GetSurveys(int StudyWaveId,int ConditionId);
        [OperationContract]
        List<Survey> GetAllSurveys();
        [OperationContract]
        Survey GetSurvey(Guid SurveyId);
        [OperationContract]
        bool UpdateSurvey(Survey mySurvey);
        [OperationContract]
        bool UpdateSurveyDisplayOrder(int StudyWaveId, Guid SurveyId, int DisplayOrder);
        [OperationContract]
        bool RemoveSurvey(int StudyWaveId,int ConditionId, Guid SurveyId);
        [OperationContract]
        Survey CreateSurvey(int StudyWaveId,int ConditionId, out StudyWaveSurvey StudyWaveSurvey);
        [OperationContract]
        StudyWaveSurvey AssociateExistingSurvey(int StudyWaveId, int ConditionId, Guid SurveyId);
        #endregion
        #region SurveyPage
        [OperationContract]
        List<SurveyPage> GetSurveyPages(Guid SurveyId);
        [OperationContract]
        SurveyPage GetSurveyPage(int SurveyPageId);
        [OperationContract]
        bool UpdateSurveyPage(SurveyPage page);
        [OperationContract]
        SurveyPage CreateSurveyPage(Guid SurveyId,out SurveySurveyPage ssp);
        [OperationContract]
        bool DeleteSurveyPage(SurveyPage page);
        [OperationContract]
        bool UpdateDisplayOrder(Guid SurveyId, int SurveyPageId, int DisplayOrder);
        [OperationContract]
        List<SurveySurveyPage> UpdateSurveyPages(List<SurveyPage> pages, Guid SurveyId);
        [OperationContract]
        bool DeleteSurveySurveyPages(Guid SurveyId);
        [OperationContract]
        bool CreateSurveySurveyPage(SurveySurveyPage ssp);
        #endregion
        #region Session
        [OperationContract]
        void BeginSession(int IndividualId, Guid StudyId, bool IsTesting);
        [OperationContract]
        void EndSession(int IndividualId, Guid StudyId);        
        #endregion
        [OperationContract]
        bool LoginUser(string Username, string Password, out int UserId);
        [OperationContract]
        IndividualClaimsView[] GetClaimsForIndividual(string LoginName, int[] ClaimId);
        [OperationContract]
        bool ValidateUserClaims(Guid StudyId, string LoginName, int UserId, out List<string> MissingClaimNames );
        [OperationContract]
        List<string> GetResourcesForStudyId(Guid StudyId);
        [OperationContract]
        void DeleteResource(string Path, Guid StudyId);
        [OperationContract]
        bool CreateAccount(string Username, string Password);
        [OperationContract]
        void CreateClaim(string UserName, int ClaimId, string Value);
        
    }
}
